package org.zl.mybatis.use.intercept;

import java.sql.CallableStatement;
import java.sql.Statement;

import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;

@Intercepts({
	@Signature(type = ResultSetHandler.class,
			method = "handleResultSets",
			args = {Statement.class}),
	@Signature(type = ResultSetHandler.class,
			method = "handleCursorResultSets",
			args = {Statement.class}),
	@Signature(type = ResultSetHandler.class,
			method = "handleOutputParameters",
			args = {CallableStatement.class}),
	
})
public class ResultSetHandlerInterceptor implements Interceptor {

	@Override
	public Object intercept(Invocation invocation) throws Throwable {
		System.out.println("\n-------3\n" + invocation);
		System.out.println(invocation.getTarget());
		System.out.println(invocation.getMethod());
		System.out.println(invocation.getArgs() + "\n-------");
		
		Object ret = invocation.proceed();
		return ret;
	}

}
